package com.jianglin.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jianglin.mapper.RecordsMapper;
import com.jianglin.model.RecordVo;
import com.jianglin.model.Records;
import com.jianglin.service.IRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecordsServiceImpl  implements IRecordsService {
    @Autowired
    private RecordsMapper recordsMapper;

    @Override
    public PageInfo<RecordVo> findRecordsAll(int page, int limit, RecordVo recordVo) {
        PageHelper.startPage(page, limit);
        List<RecordVo> list = recordsMapper.queryRecordsAll(recordVo);
        return new PageInfo<>(list);
    }

    @Override
    public Records queryByHouIdAndTypeId(Integer houId, Integer typeId) {
        return recordsMapper.queryByHouIdAndTypeId(houId, typeId);
    }

    @Override
    public int add(Records records) {
        return recordsMapper.insert(records);
    }

    @Override
    public int delete(Long id) {
        return recordsMapper.deleteById(id);
    }

    @Override
    public int updateData(Records records) {
        return recordsMapper.updateById(records);
    }

    @Override
    public Records findById(Long id) {
        return recordsMapper.selectById(id);
    }
}
